def select_sort(nums):
    length = len(nums)
    for i in range(length - 1):
        max_num_index = i
        # 寻找当前遍历的元素中最大/最小值的index
        for j in range(i + 1, length):
            if nums[j] > nums[max_num_index]:
                max_num_index = j
        # 确定最大/最小值的index后与i交换位置
        nums[i], nums[max_num_index] = nums[max_num_index], nums[i]


if __name__ == "__main__":
    nums = [2, 4, 1, 3]
    select_sort(nums)
    print(nums)